<template>
    <div>
        <a-modal
            :title="modalTitle"
            v-model="modalShow"
            @ok="onSubmit"
            :width="1000"
            okText="确认"
            cancelText="取消"
        >
            <a-form :form="form" :label-col="labelCol" :wrapper-col="wrapperCol">
                <a-row>
                    <a-col span="12">
                        <a-form-item label="检验值">
                            <a-input v-model="form.inspectValue" />
                        </a-form-item>
                    </a-col>
                    <a-col span="12">
                        <a-form-item label="检验结果">
                            <a-select v-model="form.result">
                                <a-select-option
                                    v-for="p in dict.qcDetailResultsOptions"
                                    :key="p.code"
                                    :value="p.value"
                                >{{ p.label }}</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                </a-row>
                <a-row>
                    <a-col span="12">
                        <a-form-item label="检验记录">
                            <a-upload
                                action
                                list-type="picture"
                                :default-file-list="fileList"
                                class="upload-list-inline"
                            >
                                <a-button>
                                    <a-icon type="upload" />上传
                                </a-button>
                            </a-upload>
                        </a-form-item>
                    </a-col>
                </a-row>
            </a-form>
        </a-modal>
    </div>
</template>

<script>
import Bus from "../../../../utils/Bus";
import dict from "../../../dict.json";
export default {
    name: "modal",
    data() {
        return {
            dict,
            modalShow: false,
            codeDisabled: false,
            modalTitle: "",
            labelCol: { span: 7 },
            wrapperCol: { span: 16 },
            form: {},
            fileList: [],
        };
    },
    methods: {
        // 打开窗口
        openModal(data) {
            this.form = !!data ? data : {};
            this.modalTitle = "录入检验记录";
            this.codeDisabled = !!data;
            this.modalShow = true;
        },
        // 确定提交表单
        onSubmit() {
            Bus.$emit("entry", this.form);
            this.modalShow = false;
        },
    },
};
</script>
